作者:Xiao兔兔乖乖 | 来源:互联网 | 2023-05-18 06:30
IamattemptingtoconnecttoaremoteMySQLserverfrommylocalmachinevirtualhostusingthefoll
I am attempting to connect to a remote MySQL server from my local machine virtualhost using the following code:
我正在尝试使用以下代码从本地计算机虚拟主机连接到远程MySQL服务器:
$cOnn= mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error());
mysql_select_db($dbname, $conn) or die(mysql_error());
My problem is that I am unable to connect locally, receiving the error:
我的问题是我无法在本地连接,收到错误:
Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (10060)
无法连接到'xxx.xxx.xxx.xxx'上的MySQL服务器(10060)
This is not the case when I upload the same PHP file to the server. I am able to query the database with no problems at all.
当我将相同的PHP文件上传到服务器时,情况并非如此。我能够毫无问题地查询数据库。
I am unable to connect via command line either, but I can access cPanel which rules out the chance of my IP being banned accidentally.
我也无法通过命令行连接,但我可以访问cPanel,它排除了我的IP被意外禁止的可能性。
My local server is running PHP 5.2.9, the remote server 5.2.12
我的本地服务器运行PHP 5.2.9,远程服务器5.2.12
4 个解决方案